package com.example.rxbyhand.scheduler;


import android.os.Handler;

import java.util.concurrent.ExecutorService;

/**
 * Author by lp,on 2021/8/17/017,11:46.
 */
public class NewThreadScheduler extends Scheduler {
    final ExecutorService executorService;

    public NewThreadScheduler(ExecutorService executorService) {
        this.executorService = executorService;
    }

    @Override
    public Worker creteWorker() {
        return new NewThreadWorker(executorService);
    }

    static final class NewThreadWorker implements Worker {

        final ExecutorService mapper;

        NewThreadWorker(ExecutorService mapper) {
            this.mapper = mapper;
        }

        @Override
        public void schedule(Runnable runnable) {
            mapper.execute(runnable);
        }
    }
}
